﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace TSL.BLL
{
    public class Face
    {
        public TSL.Mode.Face GetModel(string Rule)
        {

            if (string.IsNullOrEmpty(Rule))
            {
                return null;
            }

            string[] RuleArray = Rule.Replace("$", "").Split(',');
            if (RuleArray.Length != 12)
            {
                return null;
            }

            TSL.Mode.Face face = new Mode.Face();
            face.isSingle = RuleArray[0];
            face.isDouble = RuleArray[1];
            face.cpGroupTzLen = int.Parse(RuleArray[2]);
            face.cpGroupOffset = RuleArray[3];
            face.cpLen = RuleArray[4];
            face.isHf = RuleArray[5];
            face.isSums = RuleArray[6];
            face.cpGroupShape = RuleArray[7];
            face.multiTou = RuleArray[8];
            face.cpGroupName = RuleArray[9];
            face.cpGroupPrice = RuleArray[10];
            face.cpGroupPriceRule = RuleArray[11];
            return face;
        }

        public string GetString(TSL.Mode.Face face)
        {
            if (face==null)
            {
                return "";
            }

            return string.Format("{0},{1},{2},{3},{4},{5},{6},{7},{8},{9},{10},{11}",
                face.isSingle, face.isDouble, face.cpGroupTzLen, face.cpGroupOffset,
                face.cpLen, face.isHf, face.isSums, face.cpGroupShape, face.multiTou,
                face.cpGroupName, face.cpGroupPrice, face.cpGroupPriceRule);
        }
    }
}
